<template>
	<view>
		<navbar :config="config" backColor="#000">
			
		</navbar>
		<view class="consume-top">
			<view class="consume-content">
				<text class="consume-nuns">{{ $addDecimals(commission_able , 2)  }}</text>
				<text class="consume-textXin">贡献值</text>
				<text class="consume-textXinTwo">累计贡献值：<text>{{ $addDecimals(commission_settled , 2)  }}</text></text>
				<view class="infoCircleView" @click.stop="lookExplain()" >
					<!-- <text class="iconfont3">&#xe64c;</text> -->
					<image :src="imgUrl+'/collection/infoCircle.png'" class="infoCircle"></image>
					<text >收益说明</text>
				</view>
				<view class="look-integral" @click.stop="goIntegrateBalance">
					查看积分
				</view>
			</view>
			
		</view>
		<consume-list title="贡献值明细" :status="status" :list="pointsList" :keys="{title: 'remark',
						time: 'format_create_time_millis',
						val: 'entry_value',
						type: 'bill_type'}"></consume-list>

	</view>
</template>

<script>
	import {
		userbillInfo
	} from "@/api/personal-center.js"
	import {
		getAccountInfo
	} from "@/api/login.js"
	export default {
		data() {
			return {
				imgUrl: this.$mConfig.staticUrl,
				commission_able: 0,
				commission_settled: 0,
				config: {
					// rightSlot: true,
					back: true, //false是tolbar页面 是则不写
					title: '贡献值明细',
					color: '#000',
					//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
					backgroundColor: [1, "#fff"],
					statusBarFontColor: '#1A1A1A',
					backIconColor: "#000"
					
					
					
				},
				params: {
					page: 1,
					limit: 10
				},
				pointsList: [],
				status: 'loading', //more|loading|noMore
			};
		},
		onShow() {
			this.getUserInfo()
			this.params.page = 1;
			this.pointsList = [];
			this.getList();
		},
		onReachBottom() {
			if (this.status !== 'loading' && this.status !== 'noMore') {
				this.params.page++
				this.getList()
			}
		},
		onPullDownRefresh() {
			this.params.page = 1
			this.pointsList = []
			this.getList()
		},
		methods: {
			lookExplain(){
				uni.navigateTo({
					url: '/pages/protocol/index?code=income_statement'
				})
			},
			getList() {
				this.status = 'loading';
				this.$http.get(userbillInfo, this.params).then((res) => {
					if (res && res.code == 200) {
						uni.stopPullDownRefresh()
						this.pointsList = this.pointsList.concat(res.page.list);
						if (res.page.totalPage <= res.page.currPage) {
							this.status = 'noMore'
						} else {
							this.status = 'more'
						}
						for(var i=0;i<this.pointsList.length;i++){
							if(this.pointsList[i].remark.indexOf("星店长") != -1){
								this.pointsList[i].remark="激活积分"
							}
						}
					}
				});
			},
			//获取个人信息
			getUserInfo() {
				this.$http.get(getAccountInfo).then(res => {
					if (res && res.code == 200) {
						this.commission_able = res.data.commission_able;
						this.commission_settled = res.data.commission_settled;
						uni.setStorageSync("personal", res.data)
					}
				})
			},
			// 积分余额
			goIntegrateBalance() {
				uni.navigateTo({
					url: "/pages/user/integrateBalance"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.consume-top {
		width: 712rpx;
		height:auto;
		background: #FFFFFF;
		border-radius: 19rpx 19rpx 19rpx 19rpx;
		margin-top: 19rpx;
		margin-left: 19rpx;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: center;
		padding-bottom: 38rpx;

		.consume-content {
			width: 100%;
			// flex: 1;
			display: flex;
			flex-direction: column;
			padding-top: 57rpx;
			text-align: center;

			.consume-nuns {
				font-weight: bold;
				font-size: 58rpx;
				color: #FF211F;
				line-height: 68rpx;
				margin-bottom: 8rpx;
			}
			.consume-textXin{
				font-weight: 400;
				font-size: 27rpx;
				color: #333333;
				line-height: 32rpx;
				margin-bottom: 57rpx;
			}
			.consume-textXinTwo{
				font-weight: 400;
				font-size: 25rpx;
				color: #333333;
				line-height: 27rpx;
			}
			.consume-textXinTwo text{
				font-weight: 400;
				font-size: 27rpx;
				color: #999999;
			}

			.consume-text {
				font-weight: 400;
				font-size: 27rpx;
				color: #333333;
				line-height: 27rpx;
			}
		}

		.look-integral {
			width: 635rpx;
			height: 85rpx;
			background: #FF211F;
			border-radius: 19rpx 19rpx 19rpx 19rpx;
			font-weight: 500;
			font-size: 29rpx;
			color: #FFFFFF;
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;
			margin-top: 96rpx;
			margin-left: 38rpx;
		}
	}
	.infoCircleView{
		margin-top: 23rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		text{
			font-weight: 400;
			font-size: 25rpx;
			color: #999999;
			margin-left: 12rpx;
		}
	}
	.infoCircle{
		width:27rpx;
		height:27rpx;
	
	}
</style>
